package logic

import (
	"context"
	"zye6/user_srv/modile/mysql"

	"zye6/user_srv/internal/svc"
	"zye6/user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type RegisByMobileLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRegisByMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisByMobileLogic {
	return &RegisByMobileLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RegisByMobileLogic) RegisByMobile(in *user.RegisByMobileRequest) (*user.RegisByMobileResponse, error) {
	// todo: 手机号注册

	u := mysql.UserZye6{}

	err := u.RegisterByMobile(in.Mobile)
	if err != nil {
		logx.Error("手机号注册失败", err)
		return nil, err
	}

	return &user.RegisByMobileResponse{}, nil
}
